{extend name="public:index"/}
{block name="title"}{:sysconf('title')}{/block}
{block name="content"}
<section class="My_shoucang">
    <div class="top">
        <p class="p1"><a href="javascript:history.back(-1)"></a></p>
        <p class="p2">商品收藏</p>
        <p class="p3">编辑</p>
    </div>
    <div class="shopmain">
        {if condition="$list"}
        <ul>
            {foreach name="list" item="vo"}
            <li>
                <div class="center">
                    <a href="{:url('Goods/show',array('id'=>$vo.goods_id))}"><img src="{$vo.img_url}" alt="{$vo.title}"></a>
                </div>
                <div class="right">
                    <b><a href="{:url('Goods/show',array('id'=>$vo.goods_id))}">{$vo.title}</a></b>
                    <p class="p2"><em>￥{$vo.sell_price}</em><i>￥{$vo.market_price}</i></p>
                </div>
                <div class="delete" data-id="{$vo.goods_id}">删除</div>
            </li>
            {/foreach}
        </ul>
        {else}
        <div class="nofind"><img src="__INDEX__/images/nosp.png" alt="">
            <p>暂时没有收藏，去<a href="{:url('Index/index')}">首页</a>看看</p>
        </div>
        {/if}
    </div>
</section>
<script type="text/javascript">
    $('.My_shoucang .shopmain ul li .delete').click(function(){
        var obj = $(this);
        var goodsId = obj.data('id');
        $.ajax({
            url: "{:url('Goods/collGoods')}",
            type: "POST",
            data: {'goodsId':goodsId,'action':'cancel'},
            dataType: "JSON",
            success: function(data) {
                if (data.code == 0) {
                    obj.parent().remove();
                } else {
                    layer.msg(data.msg,{'icon':5});
                }
            }
        });
    });
</script>
{/block}